var gulp = require('gulp'),  
    minifycss = require('gulp-minify-css'),
    jshint = require('gulp-jshint'),
    uglify = require('gulp-uglify'),
    rename = require('gulp-rename'),
    concat = require('gulp-concat'),
    notify = require('gulp-notify'),
    livereload = require('gulp-livereload');

//语法检查
gulp.task('lint', function() {
   return gulp.src('src/js/*.js')
    .pipe(jshint())
    .pipe(jshint.reporter('default'));
});

//压缩CSS
gulp.task('css', function() {
    return gulp.src('src/css/*.css')
    .pipe(minifycss())
    .pipe(rename({suffix: '.min'}))
    .pipe(gulp.dest('dist/css/'))
    .pipe(notify({message: 'complete'}));
});

//压缩JS
gulp.task('js', function() {
    gulp.src('src/js/*.js')
    .pipe(rename({suffix: '.min'}))
    .pipe(uglify())
    .pipe(gulp.dest('dist/js'))
    .pipe(notify({message: 'complete'}));
});

//watch
gulp.task('watch', function() {

  // 看守所有.css档
  gulp.watch('src/css/*.css', ['css']);

  // 看守所有.js档
  gulp.watch('src/js/*.js', ['js']);

});

//设置执行任务
gulp.task('default', function(){

    gulp.run('lint','js','css');

});
